<?php
/*
+---------------------------------------------------------------+
|        e107 website system
|        Easy Admin Page by Cameron. (www.e107coders.org)
|        a part of Your_plugin v3.1  multilanguage by Juan  Reseau.li
|        Released under the terms and conditions of the
|        GNU General Public License (http://gnu.org).
|		 Suitable only for e107 v0.7
+---------------------------------------------------------------+
*/

require_once("../../../class2.php");
if(!getperms("P")){ header("location:".e_BASE."index.php"); exit; }
require_once(e_ADMIN."auth.php");

      $text = "<font size='5'> e107bb Configuration</font><br/><br/>";

     if(isset($_POST['submit'])) //if submit has been pushed to create a monster
     {
     $getconf="SELECT * from ".$mySQLprefix."bbconf where conf_name='installed'";
      $getconf2=mysql_query($getconf) or die(mysql_error());
	$getconf3=mysql_fetch_array($getconf2);
if ($getconf3[conf_result]==0) 
{
	   $prefix=$_POST['prefix'];
	   $path=$_POST['path']."/";
	   $passmode=$_POST['passmode'];

$sql = 'INSERT INTO `'.$mySQLprefix.'bbconf` VALUES (\'prefix\', \''.$prefix.'\');';
mysql_query($sql) or die("Could not set the phpBB prefix:  " . $sql .  "error: " . mysql_error());
$sql = 'INSERT INTO `'.$mySQLprefix.'bbconf` VALUES (\'url\', \''.$path.'\');';
mysql_query($sql) or die("Could not set the URL:  " . $sql .  "error: " . mysql_error());
$sql = 'INSERT INTO `'.$mySQLprefix.'bbconf` VALUES (\'passmode\', \''.$passmode.'\');';
mysql_query($sql) or die("Could not set the phpBB prefix:  " . $sql .  "error: " . mysql_error());
$sql = 'UPDATE `' . $mySQLprefix . 'bbconf` SET `conf_result` = \'1\' WHERE `conf_name` = \'installed\';';
mysql_query($sql) or die("Could not set installed:  " . $sql .  "error: " . mysql_error());

$text .= "Installed!";
}
else
{
	   $prefix=$_POST['prefix'];
	   $path=$_POST['path'];
	   $passmode=$_POST['passmode'];

$sql = 'UPDATE `'.$mySQLprefix.'bbconf` SET (\'url\', \''.$path.'\');';
mysql_query($sql) or die("Could not set the URL:  " . $sql .  "error: " . mysql_error());
$sql = 'UPDATE `'.$mySQLprefix.'bbconf` SET (\'passmode\', \''.$passmode.'\');';
mysql_query($sql) or die("Could not set the phpBB prefix:  " . $sql .  "error: " . mysql_error());
$sql = 'UPDATE `'.$mySQLprefix.'bbconf` SET `conf_result` = \''.$prefix.'\' WHERE `conf_name` = \'prefix\';';
mysql_query($sql) or die("Could not set installed:  " . $sql .  "error: " . mysql_error());
$sql = 'UPDATE `'.$mySQLprefix.'bbconf` SET `conf_result` = \''.$path.'\' WHERE `conf_name` = \'url\';';
mysql_query($sql) or die("Could not set installed:  " . $sql .  "error: " . mysql_error());
$sql = 'UPDATE `'.$mySQLprefix.'bbconf` SET `conf_result` = \'1\' WHERE `conf_name` = \'installed\';';
mysql_query($sql) or die("Could not set installed:  " . $sql .  "error: " . mysql_error());

$text .= "Installed!";
}
     }
     
     else
    {
     $getconf="SELECT * from ".$mySQLprefix."bbconf where conf_name='installed'";
      $getconf2=mysql_query($getconf) or die(mysql_error());
	$getconf3=mysql_fetch_array($getconf2);
       $text .= "<form action='install.php' method='post'>";
       $text .= "You need now to complete this: <br/>";
       $text .= "phpBB Prefix:<br/>";
if ($getconf3[conf_result]==0) 
{
$prefixvalue="phpbb_";
$pathvalue="";
}
else
{
      $geturl="SELECT * from ".$mySQLprefix."bbconf where conf_name='url'";
      $geturl2=mysql_query($geturl) or die(mysql_error());
	$geturl3=mysql_fetch_array($geturl2);
      $getprefix="SELECT * from ".$mySQLprefix."bbconf where conf_name='prefix'";
      $getprefix2=mysql_query($getprefix) or die(mysql_error());
	$getprefix3=mysql_fetch_array($getprefix2);
$prefixvalue=$getprefix3[conf_result];
$pathvalue=$geturl3[conf_result];
}
       $text .= "<input class='tbox' type='text' name='prefix' size='15' value='".$prefixvalue."'><br/>";
       $text .= "phpBB Path:<br/>";
       $text .= "<input class='tbox' type='text' name='path' size='15' value='".$pathvalue."'>(full URL: http://www.example.org/e107/mye107bbforum/) with the final \"/\"<br/>";

$text .= "<input name='loginmode' value='auto' type='hidden'>";
$text .= "<br/>When the $cmsname password is not the same of the e107 password:<br/>
<input name='passmode' value='message' type='radio' disabled> Show a message to login or to do a password recovery (BETA, to enable edit this file)<br/>
<input name='passmode' value='auto' type='radio' CHECKED> Change the password automatically.";
       $text .= "<br/><input class='button' type='submit' name='submit' value='Continue'>";
       $text .= "</form>";  

    }

$ns -> tablerender("e107bb Configure", $text);

require_once(e_ADMIN."footer.php");

?>
